var model = require('../model/wordSchema');

module.exports = function(app){

	// 发表文本
	app.get('/word/add', function(req, res){
		if (req.session.user_id) {
			var data = {
				userId: req.session.user_id,
				userName: req.session.user_name,
				word: req.query.word
			}
			model.create(data, function(err, docs) {
				if (err) {
					res.send(err);
				} else {
					res.json({code: '0', data: [data]});
				}
			})
		}else {
			res.json({code: -100, msg: '您还没有登录'})
		}
	})

}